package com.aqielife.netty.simple;

import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Response<T> implements Serializable {
    private int code;


    private T data;

    private String msg;

    public static <T> Response<T> data(int code, T data, String msg) {
        return new Response<>(code, data, data == null ? "暂无承载数据" : msg);
    }

    public static TextWebSocketFrame ok(String msg){
        return new TextWebSocketFrame(msg);
    }
}
